package merge_sort;

import java.io.*;

/**
 * @Author: sfy
 * @Date: 2024/1/25 17:05
 * @Description: 归并模板
 */
public class Main {
    static BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter printWriter = new PrintWriter(new BufferedOutputStream(System.out));
    static int[] arr = new int[100010];
    static int[] res = new int[arr.length];
    public static void main(String[] args) throws IOException {
        int n = Integer.parseInt(bufferedReader.readLine());
        String[] split = bufferedReader.readLine().split(" ");
        for (int i = 0; i < n; i++) arr[i] = Integer.parseInt(split[i]);
        merge_sort(arr,0, n-1);
        for (int i = 0; i < n; i++) System.out.print(arr[i]+" ");
    }

    private static void merge_sort(int[] arr,int l,int r){
        if(l>=r) return;
        int mid = l+r>>1;
        merge_sort(arr,l,mid);
        merge_sort(arr,mid+1,r);
        int num = 0,i = l,j=mid+1;
        while(i<=mid&&j<=r){
            if(arr[i]<arr[j]) res[num++]=arr[i++];
            else res[num++] = arr[j++];
        }
        while(i<=mid) res[num++] = arr[i++];
        while(j<=r) res[num++] = arr[j++];
        for(i = l,j=0;i<=r;i++,j++){
            arr[i] = res[j];
        }
    }
}
